package com.cheng.student.controller.servlet;

import com.cheng.student.service.StudentServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "GetStudentValuesServlet", value = "/teacher/GetStudentValuesServlet")
public class GetStudentValuesServlet
        extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {

        String key = request.getParameter("key");

        //校验
        if(key == null|| "".equals(key))
        {
            return;
        }
        //通过
        StudentServiceImpl studentService = new StudentServiceImpl();

        String suchValuesJson = null;
        try
        {

            suchValuesJson = studentService.getSuchValuesJson(key);

        }
        catch (JsonProcessingException e)
        {
            return;
        }
        response.getWriter().write(suchValuesJson);

    }
}
